<extend name="./app/Tpl/Public/template.html" />
<block name="content_body">
	<div class="pad-lr-10">
	    <div style="padding:10px; overflow:hidden;">
	    	<div class="main_top" style="clear:both;"><h4>温馨提示：</h4>
    			<ul>
    				<li class="green">1.订货数量：如果该商品单位是个，进货实际是箱，请将箱核算成个，并在商品备注上填写 实际的箱数</li>
    			</ul>
	    	</div>
	    </div>
	    <form name="form_edit" id="form_edit" action="{:U('doUpd')}" method="post">
	    	<input type="hidden" name="id" id="id" value="{$detail.id}">
	    	<input type="hidden" name="product_stock_status" id="product_stock_status" value="{$detail.product_stock_status}">
	        <table width="100%" cellpadding="2" cellspacing="1" class="table_form">
	        	<caption>商品信息</caption>
	            <tr>
	                <th width="100"><span class="required">*</span>商品代码:</th>
	                <td width="300">
	                	{$detail.product_id}
	                	
	                </td>
	                <td><div id="product_codeTip"></div></td>
	            </tr>
	            <tr>
	                <th width="100"><span class="required">*</span>商品名称:</th>
	                <td width="300">
	                	{$detail.product_name}
	                </td>
	                <td><div id="product_nameTip"></div></td>
	            </tr>
	            <tr>
	                <th><span class="required">*</span>订货数量:</th>
	                <td>
	                	<input type="text" name="product_num" id="product_num" class="input-text-long" value="{$detail.product_num}">{$product.unit}
	                </td>
	                <td><div id="product_numTip"></div></td>
	            </tr>	            
	            <tr>
	                <th><span class="required">*</span>订货金额:</th>
	                <td>
	                	<input type="text" name="product_amount" id="product_amount" class="input-text-long" value="{$detail.product_amount}">
	                </td>
	                <td><div id="product_amountTip"></div></td>
	            </tr>
	            <tr>
	                <th><span class="required">*</span>实际订货日期:</th>
	                <td>
	                	<input type="text" name="product_order_date" id="product_order_date" class="input-text-long" value="{$detail.product_order_date}">
	                </td>
	                <td><div id="product_order_dateTip"></div></td>
	            </tr>
	            <tr>
	                <th>实际到货日期:</th>
	                <td>
	                	<input type="text" name="product_send_date" id="product_send_date" class="input-text-long" value="{$detail.product_send_date}">
	                </td>
	                <td><div id="product_order_dateTip"></div></td>
	            </tr>
	            <tr>
	                <th>商品备注:</th>
	                <td>
	                	<textarea name="product_content" id="product_content" cols="30" rows="3">{$detail.product_content}</textarea>
	                </td>
	                <td><div id="product_contentTip"></div></td>
	            </tr>
	        </table>
            <table width="100%" cellpadding="2" cellspacing="1" class="table_form">
	        	<caption>供应商信息</caption>
	            <tr>
	                <th  width="100">供应商名称:</th>
	                <td  width="300">
	                	<input type="button" id="dialogSupplyerBtn" value="选择供应商" onclick="redirect('{:U('Shop/SupplyerManage/showDialog',array('product_code'=>$detail['product_code']))}',true)" >
	                	<input type="hidden" name="supplyer_id" id="supplyer_id"  value="{$detail.supplyer_id}">
	                </td>
	                <td><div id="supplyer_idTip"></div></td>
	            </tr>	       
	            <tr>
	                <th><span class="required">*</span>详细信息:</th>
	                <td>
	                	<textarea name="supplyer_content" id="supplyer_content" cols="30" rows="3">{$detail.supplyer_content}</textarea>
	                </td>
	                <td><div id="supplyer_contentTip"></div></td>
	            </tr>
	        </table>
	        <table width="100%" cellpadding="2" cellspacing="1" class="table_form">
        	<caption>店铺信息</caption>
	            <tr>
	                <th width="100">店铺名称:</th>
	                <td width="300">
	                	{$detail.shop.title}：{$detail.shop.name}
	                </td>
	                <td></td>
	            </tr>
	            <tr>
	                <th><span class="required">*</span>店铺详细信息:</th>
	                <td>
	                	<textarea name="shop_content" id="shop_content" cols="30" rows="3">{$detail.shop_content}</textarea>
	                </td>
	                <td><div id="shop_contentTip"></div></td>
	            </tr>
	            <tr>
	                <th><span class="required">*</span>操作店员信息:</th>
	                <td>
	                	<textarea name="shop_user_content" id="shop_user_content" cols="30" rows="3">{$detail.shop_user_content}</textarea>
	                </td>
	                <td><div id="shop_user_contentTip"></div></td>
	            </tr>
	            <tr>
		            <td colspan="3">
			            <div class="explain-col">
			            	<input type="button" name="submitBtn" value="修改" onclick="doSubmit()">
			            	<if condition="$detail['product_stock_status'] eq '0'">
			            		<input type="button" name="submitBtn" value="入库完毕" onclick="doStockStatus('1')">
			            	<else/>
			            		<input type="button" name="submitBtn" value="入库取消" onclick="doStockStatus('0')">
			            	</if>
	        				<input type="button" name="reset" value="返回列表" onclick='redirect("{:U('index')}")'>
			        	</div>
		            </td>
	            </tr>
	        </table>
	    </form>
	</div>
	<div id="dialog_content" title="弹出框"></div>
<script type="text/javascript" src="__ROOT__/statics/scripts/jquery/jquery.ui.datepicker-zh.js"></script>
<script type="text/javascript">
function doSubmit(){
	$('#form_edit').submit();
}
function doStockStatus(product_stock_status){
	document.forms['form_edit'].product_stock_status.value = product_stock_status;
	$('#form_edit').attr('action',"{:U('doStockStatus')}");
	$('#form_edit').submit();
}

function dealDialogSupplyer(supplyer){
	$("#supplyer_id").val(supplyer.id);
	$("#supplyer_content").val(supplyer.content);
}
$(function(){
	$.datepicker.setDefaults( $.datepicker.regional[ "zh" ] );
	$( "#product_order_date" ).datepicker({
		dateFormat:'yy-mm-dd',
		changeYear: true,
		onClose:function(){
			$(this).blur();
		}
	});	
	
	$( "#product_send_date" ).datepicker({
		dateFormat:'yy-mm-dd',
		changeYear: true,
		onClose:function(){
			$(this).blur();
		}
	});	
	
	$( "#dialog_content" ).dialog({
		autoOpen: false,
		width:650,
		height:400
	});

	$.formValidator.initConfig({
		formID:"form_edit",
		wideWord:false,
		submitOnce:true
	});
	
	var tips = {
		"product_numTip":"请输入正确的商品数量",
		"product_amountTip":"请输入正确的订货金额",
		"supplyer_contentTip":"请输入正确的供应商信息",
		"shop_contentTip":"请输入正确的店铺信息",
		"shop_user_contentTip":"请输入正确的操作员信息",
		"product_order_date":"请输入实际订货日期",
		"product_send_date":"请输入实际到货日期（未到货请不要填写）"
	}
	$("#product_num").formValidator({
		onFocus:tips.product_numTip,
	}).inputValidator({
		min:1,
		max:9999,
		type:"value",
		onError:"数量范围1-9999"
	})
	
	$("#product_amount").formValidator({
		onFocus:tips.product_amountTip,
	}).inputValidator({
		min:0,
		type:"value",
		onError:"金额不能范围"
	});
	
	$("#supplyer_content").formValidator({
		onFocus:tips.supplyer_contentTip,
	}).inputValidator({
		min:1,
		onError:"供应商信息不能为空"
	});
	
	$("#shop_content").formValidator({
		onFocus:tips.shop_contentTip,
	}).inputValidator({
		min:1,
		onError:"商铺信息不能为空"
	});
	
	$("#shop_user_content").formValidator({
		onFocus:tips.shop_user_contentTip,
	}).inputValidator({
		min:1,
		onError:"操作店员信息不能为空"
	});
	
	
	$("#address").formValidator({
		onFocus:tips.addressTip,
	}).inputValidator({
		min:2,
		max:100,
		onError:"详细地址不正确（2-50个字符）"
	});
	
	$("#product_order_date").formValidator({
		onFocus:tips.product_order_dateTip,
	}).inputValidator({
		type:"date",
		onError:"格式不正确"
	});
	
	$("#product_send_date").formValidator({
		onFocus:tips.product_send_dateTip,
	}).inputValidator({
		empty:true,
		onEmpty:"货到时填写",
		onError:"格式不正确"
	});
		
})


</script>
</block>	